$(function () {
    let channel = getQueryString("channel");
    let url = '../sharebill/list';
    if (channel) {
        url += '?channel=' + channel;
    }

    $("#jqGrid").jqGrid({
        url: url,
        datatype: "json",
        colModel: [
            {label: 'id', name: 'id', index: 'id', key: true, align: "center", hidden: true},
            {
                label: '创建时间', name: 'createTimeView', index: 'create_time_view', align: "center", width: 80,
                formatter: function (value) {
                    return transDate(value, 'yyyy-MM-dd');
                }
            },
            {label: '访问ip', name: 'ip', index: 'ip', align: "center", width: 80},
            {label: '浏览器标识', name: 'appCodeName', index: 'appCodeName', align: "center", width: 80},
            {label: '硬件平台', name: 'platform', index: 'platform', align: "center", width: 80}],
        viewrecords: true,
        height: 385,
        rowNum: 10,
        rowList: [10, 30, 50],
        rownumbers: true,
        rownumWidth: 25,
        autowidth: true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader: {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames: {
            page: "page",
            rows: "limit",
            order: "order"
        },
        gridComplete: function () {
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({"overflow-x": "hidden"});
        }
    });
});

let vm = new Vue({
    el: '#rrapp',
    data: {
        showList: true,
        title: null,
        apiShareBill: {},
        ruleValidate: {
            name: [
                {required: true, message: '名称不能为空', trigger: 'blur'}
            ]
        },
        q: {
            name: ''
        }
    },
    methods: {
        query: function () {
            vm.reload();
        },
        reload: function (event) {
            vm.showList = true;
            let page = $("#jqGrid").jqGrid('getGridParam', 'page');
            $("#jqGrid").jqGrid('setGridParam', {
                postData: {'name': vm.q.name},
                page: page
            }).trigger("reloadGrid");
            vm.handleReset('formValidate');
        }
    }
});